package me.stephenj.experiment2.mapper;

import me.stephenj.experiment2.model.PhoneNrs;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

/**
 * @Title PhoneNrsMapper.java
 * @Description PhoneNrsMapper类
 * @author 张润天
 * @Time 2020/4/21 12:36
 * @version v0.01
 */

@Component
public interface PhoneNrsMapper {

    /**
     * @Title Method
     * @Description 查看最大编号
     */
    @Select("SELECT MAX(`ID`) FROM PhoneNrs")
    int max();

    /**
     * @Title Method
     * @Description 根据电话组编号获取电话编号
     */
    @Select("SELECT * FROM PhoneNrs WHERE ID=#{ID}")
    PhoneNrs getAll(int ID);

    /**
     * @Title Method
     * @Description 添加新的电话组
     */
    @Insert("INSERT INTO PhoneNrs (ID, PhoneNrIDA, PhoneNrIDB, PhoneNrIDC, PhoneNrIDD) VALUE (#{ID}, #{PhoneNrIDA}, #{PhoneNrIDB}, #{PhoneNrIDC}, #{PhoneNrIDD})")
    int insert(PhoneNrs phoneNrs);

    /**
     * @Title Method
     * @Description 修改电话组信息
     */
    @Update("UPDATE PhoneNrs SET PhoneNrIDA=#{PhoneNrIDA}, PhoneNrIDB=#{PhoneNrIDB}, PhoneNrIDC=#{PhoneNrIDC}, PhoneNrIDD=#{PhoneNrIDD} WHERE ID=#{ID};")
    int update(PhoneNrs phoneNrs);

    /**
     * @Title Method
     * @Description 删除电话组
     */
    @Delete("DELETE FROM PhoneNrs WHERE ID=#{ID}")
    int delete(int ID);
}
